﻿using System;
using System.Collections.Generic;
using System.Text;
using SharpSvn;

namespace TSVNAddin.SVN
{
	public class SVNClientAdapter
	{
        public virtual bool IsWorkingCopy(string path)
        {
            return GetInfo(path) != null;
        }

		private SVNInfoArgs GetInfo(string path)
		{
			using (SvnClient client = new SvnClient())
			{
				SvnInfoEventArgs info;
				SvnTarget svnTarget = SvnTarget.FromString(path);

				try
				{
					client.GetInfo(svnTarget, out info);
				}
				catch (SvnException ex)
				{
					return null;
				}

				return new SVNInfoArgs()
				{
					RepositoryRoot = info.RepositoryRoot,
					Uri = info.Uri
				};
			}
		}
	}
}
